package com.qfedu.micrograss.grass.service.impl;

import com.qfedu.common.core.entity.Grass;
import com.qfedu.common.core.utils.UserUtils;

import com.qfedu.micrograss.grass.mapper.GrassMapper;
import com.qfedu.micrograss.grass.param.GrassParam;
import com.qfedu.micrograss.grass.service.GrassService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 以梦为马，以汗为泉，不忘初心，不负韶华
 * @author zqh (ZQH)
 * @date 2025/6/5 19:59
 * @version 1.0
 */
@Service
public class GrassServiceImpl implements GrassService {
    @Resource
    private GrassMapper grassMapper;


    @Override
    public void addGrass(GrassParam grassParam) {

        Integer uid = UserUtils.getUid();

        Grass grass = new Grass();
        BeanUtils.copyProperties(grassParam,grass);

        String imPath = String.join(",", grassParam.getImgList());
//        String imPath = grassParam.getImgList().stream().collect(Collectors.joining(","));
        grass.setImgPath(imPath);
        grass.setUid(uid);
        grassMapper.insert(grass);

        //送积分，在User中实现，进行服务调用


    }


}

